class Solution(object):
    def canConstruct(self, ransomNote, magazine):
        """
        :type ransomNote: str
        :type magazine: str
        :rtype: bool
        """
        freq = {}
        for a in magazine:
            freq[a] = freq.get(a, 0) + 1
        for b in ransomNote:
            if b not in freq or freq[b] == 0:
                return False
            else:
                freq[b] -= 1
        return True

if __name__ == '__main__':
    ransomNote = "aa"
    magazine = "aab"
    print(Solution().canConstruct(ransomNote, magazine))